#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 23:24
# @Author: 刘航
# @Email: xxx@gmail.com
# @File：add_customer_care_page.py
"""
添加客户关怀界面
"""
from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from selenium.webdriver.support.select import Select

class AddCustCarePage(BasePage):
    click_customer_name_locator = (By.ID,"customer_name")
    select_customer_name_locator = (By.CSS_SELECTOR,"#datas > tr:nth-child(1) > td:nth-child(1) > input:nth-child(1)")
    save_customer_name_locator = (By.CSS_SELECTOR,"div.ui-dialog:nth-child(9) > div:nth-child(3) > div:nth-child(1) > button:nth-child(1)")
    care_title_locator = (By.ID,"name")
    care_time_locator = (By.ID,'care_time')
    save_btn_locator  = (By.CSS_SELECTOR,".table > thead:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > input:nth-child(1)")
    def click_customer_name(self):
        """客户框"""
        self.driver.find_element(*self.click_customer_name_locator).click()
    def select_customer_name(self):
        """选择客户"""
        self.driver.find_element(*self.select_customer_name_locator).click()
    def save_customer_name(self):
        """点击保存客户名"""
        self.driver.find_element(*self.save_customer_name_locator).click()
    def care_title(self,name):
        """关怀主题"""
        self.driver.find_element(*self.care_title_locator).send_keys(name)
    def care_time(self,time):
        """关怀时间"""
        self.driver.find_element(*self.care_time_locator).send_keys(time)
    def click_save(self):
        """点击保存"""
        self.driver.find_element(*self.save_btn_locator).click()

    def add_cust_care(self,care_title,care_time):
        self.click_customer_name()
        self.select_customer_name()
        self.save_customer_name()
        self.care_title(care_title)
        self.care_time(care_time)
        self.click_save()

